/* ----------------------------------------------------------------------------------------------------------------
 *  VisibleCore
 * ----------------------------------------------------------------------------------------------------------------
 */
package pure.engine.core
{
	import flash.display.BitmapData;
	import flash.filters.BitmapFilter;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import pure.debug.Logger;
	
	use namespace ns_despair;
	
	
	/**
	 * 可视抽象类
	 * [Author] - PURE
	 * 
	 */
public class VisibleCore implements IVisible
{
	
	
	
	//======================
	// Const
	//======================
	
	
    public static const TWO_PI:Number             =  2.0 * Math.PI;
	public static const ONE_EIGHTY_DIV_PI:Number  =  180 / Math.PI;
	public static const PI_DIV_ONE_EIGHTY:Number  =  Math.PI / 180;
	
	
	
	
	
	//======================
	// Property
	//======================
	
	
	/**
	 * 是否可交互
	 */
	public function get interactive():Boolean 
	{
		return m_interactive; 
	}
	
	public function set interactive(b:Boolean):void 
	{
		m_interactive = b; 
	}

	
	/**
	 * 是否可见
	 * 
	 * [Hint] - 为false，更新时...
	 *          ① 渲染器，二级画像缓存不会更新，Flagment画像为空
	 *          ② 实体，实体残像不会出现在世界
	 *          ③ 动画渲染器，移除tick侦听
	 * 
	 *          为true，更新时... 
	 *          ① 渲染器，二级画像缓存更新，Flagment画像更新
	 *          ② 实体，实体残像出现在世界
	 *          ③ 动画渲染器，加入tick侦听
	 */
	public function get visible():Boolean 
	{ 
		return m_visible;
	}
	
	public function set visible(b:Boolean):void
	{ 
		// Override !!
	}

	
	/**
	 * 弧度
	 * 
	 * [Hint] - 0 ~ PI*2
	 */
	public function get angle():Number 
	{ 
		return m_angle; 
	}
	
	public function set angle(v:Number):void 
	{ 
		// Override !!
	}
	
	
	/**
	 * 角度
	 * 
	 * [Hint] - 0 ~ 360
	 */
	public function get rotation():Number 
	{
		var n:Number = m_angle * ONE_EIGHTY_DIV_PI;
		return n < 0 ? n + 360 : n;
	}
	
	public function set rotation(v:Number):void 
	{
		this.angle = (v % 360) * PI_DIV_ONE_EIGHTY; 
	}
	

	
	
	
	//======================
	// Filter
	//======================
	
	
	/**
	 * 加入滤镜
	 */
	public function addFilter(F:BitmapFilter):void
	{
		if (!m_filterList)
		{
			m_filterList = [];
		}
		m_filterList.push(F);
		m_numFilter++;
	}
	
	
	/**
	 * 清空滤镜
	 */
	public function clearFilter():void
	{
		m_filterList.length = m_numFilter = 0;
	}
	
	
	

	/* ----------------------------------------------------------------------------------------------------------------
	 * ★★★★★★★★★★★★★★★★★★★★★  private  ★★★★★★★★★★★★★★★★★★★★★
	 * ----------------------------------------------------------------------------------------------------------------
	 */
	
	
		
	
	/**
	 * 毁灭
	 */
	ns_despair function destroy():void
	{
		m_filterList  =  null;
		m_realRect    =  null;
	}
	
	
	
	
	
	//======================
	// Member
	//======================
	
	
	ns_despair var m_x:Number = 0;  // 坐标X
	
	ns_despair var m_y:Number = 0;  // 坐标Y
	
	ns_despair var m_id:int;  // 识别
	
	ns_despair var m_name:String;  // 名字

	ns_despair var m_range:Number = 0;  // 面积
		
	ns_despair var m_angle:Number = 0;  // 弧度
	
	ns_despair var m_visible:Boolean = true;  // 是否可见
		
	ns_despair var m_interactive:Boolean = true;  // 是否可交互

	ns_despair var m_filterList:Array;  // 滤镜列表
	
	ns_despair var m_numFilter:int;  // 滤镜数目
	
	ns_despair var m_realRect:Rectangle;  // 真实矩形（碰撞检测，会产生形变或透明度变化的渲染器通常不能使用）


	
	//======================
	// Cached Object
	//======================

	
	protected static var cachedPoint:Point = new Point();
	
	protected static var cachedZeroPoint:Point = new Point();


	
}
}